using System;
using System.Collections.Generic;
using System.Text;

using IGlobalist.Cms.Model;

namespace IGlobalist.Cms.DataAccess
{
    /// <summary>
    /// Implenment BaseDAO class, IClassDA0 class 
    /// </summary>
    public class ClassDAO : BaseDAO, IClassDAO 
    {
        #region IClassDAO Members
        /// <summary>
        /// Get class object by Id
        /// </summary>
        /// <param name="id">Id of class</param>
        /// <returns>Class object</returns>
        public ICmsClass GetClass(long id)
        {
            return (ICmsClass)ExecuteQueryForObject("GetClass", id);
        }
        /// <summary>
        /// Get class object by name
        /// </summary>
        /// <param name="name">Name of class</param>
        /// <returns>Class object</returns>
        public ICmsClass GetClassByName(string name)
        {
            return (ICmsClass)ExecuteQueryForObject("GetClassByName", name);
        }
        /// <summary>
        /// Get class list
        /// </summary>
        /// <returns>Class list</returns>
        public IList<ICmsClass> GetAllClassList()
        {
            
            System.Collections.IList list = ExecuteQueryForList("GetAllClassList", null);
            IList<ICmsClass> retList = new List<ICmsClass>();
            if (list != null)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    retList.Add((ICmsClass)list[i]);
                }
            }
            return retList;
        }
        /// <summary>
        /// Get class list by classTypeId
        /// </summary>
        /// <param name="classTypeID">Id of class type</param>
        /// <returns>Class list</returns>
        public IList<ICmsClass> GetClassListByClassTypeID(short classTypeID)
        {
            System.Collections.IList list = ExecuteQueryForList("GetClassListByClassTypeID", classTypeID);
            IList<ICmsClass> retList = new List<ICmsClass>();
            if (list != null)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    retList.Add((ICmsClass)list[i]);
                }
            }
            return retList;
        }
        /// <summary>
        /// Insert class
        /// </summary>
        /// <param name="clazz">Class object</param>
        /// <returns>Id of class</returns>
        public long InsertClass(ICmsClass clazz)
        {
            return (long) ExecuteInsert("InsertClass", clazz);
        }
        /// <summary>
        /// Update class
        /// </summary>
        /// <param name="clazz">Class object</param>
        public void UpdateClass(ICmsClass clazz)
        {
            ExecuteUpdate("UpdateClass", clazz);
        }

        /// <summary>
        /// Delete class by Id
        /// </summary>
        /// <param name="id">Id of class</param>
        public void DeleteClass(long id)
        {
            ExecuteDelete("DeleteClass", id);
        }

        #endregion
    }
}
